#include "widget.h"
#include "ui_widget.h"
#include <QLabel>
#include <QResizeEvent>
#include <QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->label->setGeometry(0,0,this->geometry().width(), this->geometry().height());
    QPixmap pixmap(":/1.jpg");
//    pixmap = pixmap.scaled(this->geometry().width(),this->geometry().height());
    ui->label->setPixmap(pixmap);
    ui->label->setScaledContents(true); //自动拉伸填充
    //随着窗口拉伸，图片不能自适应
}

Widget::~Widget()
{
    delete ui;
}

void Widget::resizeEvent(QResizeEvent *event)
{
    // 事件
    QSize size = event->size();
    qDebug() << size;
    ui->label->setGeometry(0,0,size.width(), size.height());
}
